Headcannon Game Engine Script Commands - Function Control
Index:
Function Calling:
(D) (E) | _CallFunc |
(D) (E) | _RunFunc |
(D) (E) | _CallFunc_Game |
(D) (E) | _RunFunc_Game |
Function Stopping:
(D) (E) | _StopFunc |
(D) (E) | _StopFunc_Game |
(D) (E) | _StopCurrentFunc |
Flow Control:
(D) (E) | _Loop |
(D) (E) | _FuncBreak |
(D) (E) | _GoTo |
(D) (E) | _BreakTo |
Descriptions:
Function Calling:
_CallFunc
_CallFunc_Game
(ALL) (REG) (Example)
Starts the processing of another Function. The Function is added to the Function queue, and will start
no sooner than when the calling Function is stopped or reaches a Break, and no later than the
next Game Frame (The time at which it starts depends on where in the queue
the first available Function slot is)
A Function that is already in the queue will not be added again. Duplicate calls are ignored
Using the basic form of this Command, a Function of any given type may
only call another Function of the same type. (IE, "Status Script" functions
may not call G/Z/A functions, and may only call functions that exist in the
same script). Other Commands exist for allowing a Function from one aspect of
the game to control Functions from another aspect of the game
Using the "_Game" form of this Command, any Function within the game may call
a Function from the "Game", "Zone", or "Act" Functions list
Parameters:
- Func ID
ID number of the function to call. If this is a "Game",
"Zone", or "Act" function, the "G", "Z", and "A" flags
may be used. The "R" and "r" tags may
be used to obtain a Function ID from a Register
_RunFunc
_RunFunc_Game
(ALL) (REG) (Example)
Similar to the "_CallFunc" command, except the Function begins
processing immediately. The Function that issued this Command is paused, and will resume when
the given Function stops or reaches a Break. If the called function Breaks without
ending, it may process a second time during the same Game Frame, depending
on where it is placed in the Function queue
A Function that is already in the queue will not be added or run again. Duplicate calls are ignored
Using the basic form of this Command, a Function of any given type may
only call another Function of the same type. (IE, "Status Script" functions
may not call G/Z/A functions, and may only call functions that exist in the
same script). Other Commands exist for allowing a Function from one aspect of
the game to control Functions from another aspect of the game
Using the "_Game" form of this Command, any Function within the game may call
a Function from the "Game", "Zone", or "Act" Functions list
Parameters:
- Func ID
ID number of the function to run. If this is a "Game",
"Zone", or "Act" function, the "G", "Z", and "A" flags
may be used. The "R" and "r" tags may
be used to obtain a Function ID from a Register
Function Stopping:
_StopFunc
_StopFunc_Game
(ALL) (REG) (Example)
Stops the given Function from processing, and removes it from the queue
Using the basic form of this Command, a Function of any given type may
only stop another Function of the same type. (IE, "Status Script" functions
may not call G/Z/A functions, and may only call functions that exist in the
same script). Other Commands exist for allowing a Function from one aspect of
the game to control Functions from another aspect of the game
Using the "_Game" form of this Command, any Function within the game may stop
a Function from the "Game", "Zone", or "Act" Functions list
Parameters:
- Func ID
ID number of the function to stop. If this is a "Game",
"Zone", or "Act" function, the "G", "Z", and "A" flags
may be used. The "R" and "r" tags may
be used to obtain a Function ID from a Register
_StopCurrentFunc
(ALL) (Example)
Stops the Function that issued this Command from processing, and removes it from the queue
Parameters:
None
Function Flow Control:
_Loop
(ALL) (Example)
Loops back to a previous Command in the Function to perform a series of Commands
multiple times
As soon as this Command is reached, the current Function breaks (similarly to FuncBreak),
and then loops back to the given position when it resumes processing on the next "Game Frame". If the Function should
not break, use the _GoTo Command or a Do/While" Command Block instead
Although all types of Functions can use this command, each one
uses a different type of timer to keep track of how many times the loop has
processed
Parameters:
- Command To Loop To
Location of the Command within the Function that should be looped back to.
There are three ways to represent this location:
- Exact Location- Start at the beginning of the Function and count the number of Commands that come before the Command that should be looped to, but do not count their Parameters. Enter that exact value (the first Command in the Function would be "0", the second "1", etc.)
- Relative Location- Count the distance between the "Loop" Command and the Command that should be looped to (in number of Commands, do not count the Parameters). Enter that value, prefixed with either a "+" or "-" to denote the direction of the jump. (The Command immideately after the "Loop" would be "+1", the Command immediately before the "Loop" would be "-1".) To perform a wait loop without any other Commands, loop back to the "Loop" command itself by entering "+0" or "-0"
- Label- Enter the name of the Label to jump to, prefixed by an "@" symbol (To jump to the location of the label named "State2", use "@State2"
- Counter
Each type of function uses a different type of counter to keep track of
how many times the loop has been processed:
Status scripts - Status Script Counter Variable
Game Functions - Game Registers (Can use the "U" tag for "User Register")
Player Functions - Player Variables for the "Current Player" (Can use the "A" and "a" tags for standard "Active Variables" and User-Created "Active Variables", respectively)
Object Functions - Object Variables for the "Current Object" (Can use the "E" tag for "Extra Variables")
This value states the ID of the variable to use from the appropriate
listing as described above, and the noted tags can be used to specify
which part of the listing the variable belongs to. Player and Object
Functions use variables from the Player/Object that is running the
current Function
- Number of Repeats
This is the number of times the loop should be processed. A value of
-1 will cause the loop to repeat until it's broken manually. If that
setting is used, the counter that is referenced by the above parameter
will not be used at all (the "Counter" value can safely contain any ID
because its content will not be modified during an "infinite" loop)
_FuncBreak
(ALL) (Example)
Temporarily stops processing the current Function so that other Functions and the
game itself will be able to finish processing for the current "Game Frame". The
Function resumes from its current position when the game once again reaches it
for processing during the next "Game Frame"
Parameters:
None
_GoTo
(ALL) (Example)
Causes the Function to immediately and unconditionally jump to the specified position
This Command does not cause a break. The BreakTo Command
should be used if the Function should break before the jump
Parameters:
- Command To Jump To
Location of the Command that the Function should jump to to.
There are three ways to represent this location:
- Exact Location- Start at the beginning of the Function and count the number of Commands that come before the Command that should be looped to, but do not count their Parameters. Enter that exact value (the first Command in the Function would be "0", the second "1", etc.)
- Relative Location- Count the distance between the "Loop" Command and the Command that should be looped to (in number of Commands, do not the Parameters). Enter that value, prefixed with either a "+" or "-" to denote the direction of the jump. (The Command immideately after the "Loop" would be "+1", the Command immediately before the "Loop" would be "-1")
- Label- Enter the name of the Label to jump to, prefixed by an "@" symbol (To jump to the location of the label named "State2", use "@State2"
_BreakTo
(ALL) (Example)
This Command behaves as if "_FuncBreak" and "_GoTo" were used in sequence, delaying the Function for a single Game Frame and causing the Function to immediately and unconditionally jump to the specified position, where it will resume on the next Game Frame
This Command is "Safer" than using the two individually, in that it can help avoid invalid Function positioning in situations such as when modifying Functions for Objects that have already been saved to an Object Layout File, due to the fact that the Function's position is updated before the "break" rather than after
Parameters:
- Command To Jump To
Location of the Command that the Function should jump to to.
There are three ways to represent this location:
- Exact Location- Start at the beginning of the Function and count the number of Commands that come before the Command that should be looped to, but do not count their Parameters. Enter that exact value (the first Command in the Function would be "0", the second "1", etc.)
- Relative Location- Count the distance between the "Loop" Command and the Command that should be looped to (in number of Commands, do not the Parameters). Enter that value, prefixed with either a "+" or "-" to denote the direction of the jump. (The Command immideately after the "Loop" would be "+1", the Command immediately before the "Loop" would be "-1")
- Label- Enter the name of the Label to jump to, prefixed by an "@" symbol (To jump to the location of the label named "State2", use "@State2"
Examples:
#_CallFunc ;Cause the currently-processing Function queue to add Function 5 from its corresponding Function list
: 5 ;Function 5
; ----------
#_CallFunc_Game ;Cause the "Game" Function queue to add Function 8 from the current "Zone"'s Game Function list
: Z8 ;Zone-specific Function 8
_RunFunc
_RunFunc_Game
(Description)
#_RunFunc ;Cause the currently-processing Function queue to add Function 3 from its corresponding Function list and begin processing it immediately
: 3 ;Function 3
; ----------
#_RunFunc_Game ;Cause the "Game" Function queue to add Function 12 from the Game-global Function list and begin processing it immediately
: G12 ;Game-global Function 12
Function Stopping:
#_StopFunc ;Cause the currently-processing Function queue to remove and stop processing Function 17 from its corresponding Function list
: 17 ;Function 17
; ----------
#_StopFunc_Game ;Cause the "Game" Function queue to remove and stop processing Function 1 from the current "Act"'s Game Function list
: A1 ;Act-specific Function 1
_StopCurrentFunc
(Description)
#_StopCurrentFunc ;Cause the current Function to stop processing, and remove it from the current Function queue
Function Flow Control:
;Assume this Command is being processed from within an Object Function
#_Loop ;Loop back to the Label named "2" 14 times, using "Extra Variable" 1 of the "Current Object" as the counter
: @2 ;(Location) Label "2"
: E1 ;(Counter) "Extra Variable" 1 of the "Current Object"
: 14 ;(Repeats) 14 times
; ----------
;Assume this Command is being processed from within a Player Function
#_Loop ;Loop back to Label named "4" 32 times, using User-created "Active Variable 7 of the "Current Player" as the counter
: @4 ;(Location) Label "4"
: a7 ;(Counter) User-created "Active Variable 7 of the "Current Player"
: 32 ;(Repeats) 32 times
; ----------
;This Command could be used anywhere
#_Loop ;Loop back to Label named "0" infinitely
: @0 ;(Location) Label "0"
: 0 ;(Counter) No counter used in infinite repeat
: -1 ;(Repeats) Repeat Infinitely
_FuncBreak
(Description)
#_FuncBreak ;Suspend this Functon until the next Game Frame, so other parts of the game are allowed to run
_GoTo
(Description)
#_GoTo ;Cause the processing of the current Function to skip ahead [or behind] to Label named "9"
: @9 ;Label "9"
_BreakTo
(Description)
#_BreakTo ;Suspend this Function until the next Game Frame, and cause it to begin processing at the location of Label named "5" when it resumes
: @5 ;Label "5"